/*
 * HTThread.h
 *
 *  Created on: Mar 16, 2009
 *      Author: Andrzej Olchawa
 *      mailto: andrzejolchawa@gmail.com
 *      http://www.hardtechnology.org
 *      This is a part of the Armazd project, which is covered by
 *      GNU GPL v2 license.
 */

#ifndef AOTHREAD_H_
#define AOTHREAD_H_

/* Include section */
#include <string>
#include <iostream>
#include <dlfcn.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>

/* namespace declaration */
using namespace std;

/* HTThread class definition */
template<class T>
class HTThread
{

protected:

	/* Variables related with threads */
	int 		    threadHandle;
	pthread_t 	    threadId;
	pthread_attr_t  threadAttr;
	bool			interrupt;
	pthread_mutex_t agentMutex;
	int 			executionDelay;

	void setInterrupt(bool);
	static void *startRunFunc(void *);

public:

	HTThread();
	HTThread(bool);
	virtual ~HTThread();

	/* Getters and setters */
	bool isInterrupt();

	/* Functions related with thread management */
	void run();
	void pause();
	void start();
};

#endif /* AOTHREAD_H_ */
